import time

print(time.time()) #1611385190.5962877
time.sleep(3)
print(time.time()) #1611385193.6059985


# 时间戳转换为字符串
t=time.time()
print(time.ctime(t)) #Sat Jan 23 15:02:18 2021


# 将时间戳转换为元组
print(time.localtime(t))

# time.struct_time(tm_year=2021, tm_mon=1, tm_mday=23, tm_hour=15, tm_min=4, tm_sec=0, tm_wday=5, tm_yday=23, tm_isdst=0)

# 将时间戳转换为字符串
print(time.strftime('%Y-%m-%d')) #2021-01-23


# 将字符串转换为元组
print(time.strptime('2021/01/23','%Y/%m/%d'))
# time.struct_time(tm_year=2021, tm_mon=1, tm_mday=23, tm_hour=0, tm_min=0, tm_sec=0, tm_wday=5, tm_yday=23, tm_isdst=-1)


